import BaseChannel from "./base/BaseChannel";
import { ChannelID } from "./SDKConfig";
import WXChannel from "./wx/WXChannel";
import DevChannel from "./dev/DevChannel";

export default class SDKManager {

    protected channel: BaseChannel = null;

    static channel: BaseChannel;
    static getChannel() {
        return this.channel;
    }

    static init(id: ChannelID) {
        let channelID: number = this.getChannelID(id)
        console.log(' channelID  ', channelID)
        switch (channelID) {
            case ChannelID.WX:
                this.channel = new WXChannel(channelID)
                break;
            default:
                this.channel = new DevChannel(channelID)
                break;
        }

    }
    static getChannelID(id: ChannelID) {
        if (window['qq']) {
            return ChannelID.QQ;
        } else if (window['tt']) {
            return ChannelID.TT
        }
        else if (window['wx']) {
            return ChannelID.WX
        } else if (window['qg']) {
            if (window['qg']['createInterstitialAd']) {
                return ChannelID.VIVO
            } else {
                return ChannelID.OPPO
            }
        } else if (window['swan']) {
            return ChannelID.BD
        } else {
            return id
        }
    }
}
